package com.zhihu_lvliangi_android.option.mycircle.parents;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.zhihu_lvliangi_android.R;
import com.zhihu_lvliangi_android.R.array;
import com.zhihu_lvliangi_android.R.drawable;
import com.zhihu_lvliangi_android.R.id;
import com.zhihu_lvliangi_android.R.layout;
import com.zhihu_lvliangi_android.option.general.GeneralTabSlidingFragment;
import com.zhihu_lvliangi_android.option.parent.ParentActivity;
import com.zhihu_lvliangi_android.option.parent.ParentFragment;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

public class MyParententInfoActivity extends ParentActivity {

  public static	MyParententInfoActivity instance;
  @Override
	protected void onCreate(Bundle savedInstanceState) {
	  instance = this;
		super.onCreate(savedInstanceState);
	}
	
	private void initActionBar() {
		ActionBar actionBar = getSupportActionBar();
		actionBar.setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.homepage_actionbar_bg)));
		// 使自定义的普通View能在title栏显示, actionBar.setCustomView能起作用.
		actionBar.setIcon(new BitmapDrawable());
		actionBar.setDisplayHomeAsUpEnabled(true);//显示返回按钮
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			this.finish();
		default:
			return super.onOptionsItemSelected(item);
		}
	}
	
	@Override
	protected int getLayoutId() {
		return R.layout.activity_my_parentent_info;
	}

	@Override
	protected void setupViews() {
		initActionBar();
		initView();
	}

	private void initView() {
		List<ParentFragment> fragments = new ArrayList<ParentFragment>();
		List<String> tabTitles  = new ArrayList<String>();
		tabTitles.addAll(Arrays.asList(getResources().getStringArray(R.array.parents)));
		fragments.add(FatherFragment.newInstance());
		fragments.add(MotherFragment.newInstance());
		getSupportFragmentManager().beginTransaction()
		.add(R.id.container, GeneralTabSlidingFragment.newInsatnce(fragments,tabTitles)).commit();		
	}

	@Override
	protected void initialized() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void threadTask() {
		// TODO Auto-generated method stub
		
	}

	
}
